<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

    </style>
</head>
<body>
    <em>em</em>
    <div class="box" abc="hahaha" id="cont" title="这是一个title">
        <span>askjfgajdfg</span>
        hello
        <!-- 这是一个注释 -->
        <span>2</span>
    </div>
    <p>p</p>
</body>
<script>
    var obox=document.querySelector(".box");
    var aChild = obox.childNodes;
    var aAttr = obox.attributes;
    // 元素
    console.log(aChild[1]);
    // 节点的类型
    console.log(aChild[1].nodeType);
    // 节点的名
    console.log(aChild[1].nodeName);
    // 节点的值
    console.log(aChild[1].nodeValue);

    // 文本
    console.log(aChild[2]);
    console.log(aChild[2].nodeType);
    console.log(aChild[2].nodeName);
    console.log(aChild[2].nodeValue);

    // 注释
    console.log(aChild[3]);
    console.log(aChild[3].nodeType);
    console.log(aChild[3].nodeName);
    console.log(aChild[3].nodeValue);


    // 获取根节点
    console.log(document);
    console.log(document.nodeType)
    console.log(document.nodeName)
    console.log(document.nodeValue)

    // 获取属性节点
    console.log(aAttr[3]);
    console.log(typeof aAttr[3])
    console.log(aAttr[3].nodeType);
    console.log(aAttr[3].nodeName);
    console.log(aAttr[3].nodeValue);

</script>
</html>